Test of Altair interactive graphs

Graphs by country

alt.data_transformers.disable_max_rows()


# Define the 3 Charts
chart_1 = alt.Chart(data_indicators, width=300, height=300).mark_bar(opacity=.50).transform_filter(
    alt.FieldOneOfPredicate(
        field='indicators', oneOf=['s','beta'])).encode(
    x='Name:N',
    y=alt.Y('value:Q',stack=None),
    color=alt.Color('indicators', scale=alt.Scale(domain=['beta','s'], range=['red','blue'])))

chart_2 = alt.Chart(data_markups, width=300, height=300).mark_point().encode(
    x='markups:Q',
    y='markups_supplier:Q',
    tooltip=['Name', 'country', 'markups', 'markups_supplier'])

chart_3 = alt.Chart(data_flows,width = 600, height = 600).mark_rect().encode(
    x='suppliers:N',
    y='Name:N',
    color = 'value:Q',
    tooltip=['value'])


# Define the Country Dropdown
country_dropdown = alt.binding_select(options=data_renamed.country.unique())
country_select = alt.selection_single(fields=['country'], bind=country_dropdown, name='Select')


# Define interactive charts
filter_chart_1 = chart_1.add_selection(
    country_select
).transform_filter(
    country_select
).properties(title="Impact of each Sector by country")

filter_chart_2 = chart_2.add_selection(
    country_select
).transform_filter(
    country_select
).properties(title="Markups by country")

filter_chart_3 = chart_3.add_selection(
    country_select
).transform_filter(
    country_select
).properties(title="I/O parameters by country")


# Display charts
(filter_chart_1 | filter_chart_2) & (filter_chart_3)
data_flows
country Name suppliers value
0 AUS Agriculture, Hunting, Forestry and Fishing Agriculture, Hunting, Forestry and Fishing 0.252750
1 AUS Mining and Quarrying Agriculture, Hunting, Forestry and Fishing 0.001230
2 AUS Food, Beverages and Tobacco Agriculture, Hunting, Forestry and Fishing 0.337064
3 AUS Textiles and Textile Products Agriculture, Hunting, Forestry and Fishing 0.175253
4 AUS Leather, Leather and Footwear Agriculture, Hunting, Forestry and Fishing 0.150525
... ... ... ... ...
33295 USA Other Supporting and Auxiliary Transport Activ... Renting of M&Eq and Other Business Activities 0.242712
33296 USA Post and Telecommunications Renting of M&Eq and Other Business Activities 0.276128
33297 USA Financial Intermediation Renting of M&Eq and Other Business Activities 0.261084
33298 USA Real Estate Activities Renting of M&Eq and Other Business Activities 0.171947
33299 USA Renting of M&Eq and Other Business Activities Renting of M&Eq and Other Business Activities 0.414322

33300 rows × 4 columns

data_indicators
country Name indicators value
0 AUS Agriculture, Hunting, Forestry and Fishing beta 0.037056
1 AUS Mining and Quarrying beta 0.056010
2 AUS Food, Beverages and Tobacco beta 0.071822
3 AUS Textiles and Textile Products beta 0.009246
4 AUS Leather, Leather and Footwear beta 0.001927
... ... ... ... ...
6655 USA Other Supporting and Auxiliary Transport Activ... xshare 0.295707
6656 USA Post and Telecommunications xshare 0.361224
6657 USA Financial Intermediation xshare 0.416224
6658 USA Real Estate Activities xshare 0.252908
6659 USA Renting of M&Eq and Other Business Activities xshare 0.320387

6660 rows × 4 columns